VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmWatch 
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   3195
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5220
   Icon            =   "frmWatch.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3195
   ScaleWidth      =   5220
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdClose 
      Cancel          =   -1  'True
      Height          =   375
      Left            =   3960
      TabIndex        =   4
      Top             =   720
      Width           =   1095
   End
   Begin VB.CommandButton cmdSetup 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3960
      TabIndex        =   3
      Top             =   1200
      Width           =   1095
   End
   Begin VB.CommandButton cmdPage 
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3960
      TabIndex        =   2
      Top             =   240
      Width           =   1095
   End
   Begin MSComctlLib.TreeView tvWatch 
      Height          =   2655
      Left            =   120
      TabIndex        =   1
      Top             =   360
      Width           =   3495
      _ExtentX        =   6165
      _ExtentY        =   4683
      _Version        =   393217
      Indentation     =   450
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Label Label1 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2415
   End
End
Attribute VB_Name = "frmWatch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim WithEvents IRC As clsModIRC
Attribute IRC.VB_VarHelpID = -1
Dim Onlines As Integer
Dim Watches As Integer

Private Sub cmdClose_Click()
Unload Me

End Sub

Private Sub cmdPage_Click()
If WordCount(tvWatch.SelectedItem.Text) <> 1 Then
  Exit Sub
End If
If tvWatch.SelectedItem.Parent = tvWatch.Nodes(2) Then Exit Sub
Dim pgText As String

pgText = InputBox("Enter text to send in page to " & tvWatch.SelectedItem.Text, "Send Page")
If pgText = "" Then Exit Sub
IRC.SendCTCP tvWatch.SelectedItem.Text, "PAGER", pgText
frmMain.SpeechInterface.Say lang.SpeechMsg(1), True

End Sub

Private Sub cmdSetup_Click()
Unload Me
frmWatchCfg.Show

End Sub

Private Sub Form_Load()
Onlines = 0
Dim nU As Integer

Me.Caption = lang.Messages(47)
Label1.Caption = lang.Messages(48)
cmdPage.Caption = lang.Messages(49)
cmdSetup.Caption = lang.Messages(50)
cmdClose.Caption = lang.Buttons(4)

Watches = WordCount(Settings.WList)
tvWatch.Nodes.Clear

Set IRC = frmMain.IRCInterface
' first we get the total users
tvWatch.Nodes.Add , , , "Please Wait..."
tvWatch.Nodes.Add , , , "Online (0/" & CStr(Watches) & ")"
tvWatch.Nodes.Add , , , "Offline (" & CStr(Watches) & "/" & CStr(Watches) & ")"
tvWatch.Nodes(2).Expanded = True
tvWatch.Nodes(3).Expanded = False

' We default to making everyone offline.
For nU = 1 To WordCount(Settings.WList)
  tvWatch.Nodes.Add 3, tvwChild, GetWord(Settings.WList, nU), GetWord(Settings.WList, nU)
Next

' now send out the request for the current online list.
IRC.RawSend "WATCH"

End Sub

Private Sub DelUser(ByVal sUser As String)
Dim Nd As Node
For Each Nd In tvWatch.Nodes
If LCase(Nd.Key) = LCase(sUser) Then
  tvWatch.Nodes.Remove Nd.Key
  Exit For
End If
Next

End Sub

Private Sub IRC_Generic(ByVal Command As String, ByVal Data As String, ByVal Comment As String)
Select Case Command
  Case "600", "604"
   ' someone's on
   ' first remove them from the offlinelist
   DelUser GetWord(Data, 2)
   ' update the online count
   Onlines = Onlines + 1
   ' update the captions
   tvWatch.Nodes(2).Text = "Online (" & CStr(Onlines) & "/" & CStr(Watches) & ")"
   tvWatch.Nodes(3).Text = "Offline (" & CStr(Watches - Onlines) & "/" & CStr(Watches) & ")"
   ' add the user to the onlines
   tvWatch.Nodes.Add 2, tvwChild, GetWord(Data, 2), GetWord(Data, 2)
   ' all done
  Case "601"
   'someone's off
   ' first remove them from the onlinelist
   DelUser GetWord(Data, 2)
   ' update the online count
   Onlines = Onlines - 1
   ' update the captions
   tvWatch.Nodes(1).Text = "Online (" & CStr(Onlines) & "/" & CStr(Watches) & ")"
   tvWatch.Nodes(2).Text = "Offline (" & CStr(Watches - Onlines) & "/" & CStr(Watches) & ")"
   ' add the user to the offlines
   tvWatch.Nodes.Add 2, tvwChild, GetWord(Data, 2), GetWord(Data, 2)
   ' all done
  Case "607"
   If tvWatch.Nodes(1).Text = "Please Wait..." Then tvWatch.Nodes.Remove 1
End Select


End Sub


Private Sub tvWatch_BeforeLabelEdit(Cancel As Integer)
Cancel = True
' disallow all edits
End Sub
